from playwright.sync_api import sync_playwright

from configs.config import Config


def get_page(browser=Config.BROWSER_TYPE):
    pw = sync_playwright().start()
    match browser:
        case 'firefox':
            driver = pw.firefox.launch(headless=False, args=["--start-maximized"])
        case 'chrome':  # 默认chrome浏览器
            driver = pw.chromium.launch(headless=False, args=["--start-maximized"])
        case _:
            raise ValueError("不支持的浏览器类型")

    page = driver.new_page(no_viewport=True)
    return page

